package com.gitee.wsl.compose.mvi.component

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.gitee.wsl.compose.mvi.component.base.Interactable
import com.gitee.wsl.compose.mvi.component.base.Presentable

interface Projectable<Interactor, Presenter> where Interactor : Interactable, Presenter : Presentable<Presenter> {
     val interactor: Interactor
     val presenter: Presenter

    // TODO context receivers
    /**
     * Calls the specified block with the localized version of the [presenter].
     */
    @Composable
   fun contextualize(modifier: Modifier, block: @Composable (Modifier, Interactor, Presenter) -> Unit) = presenter.localized().run {
        block(
            modifier
                .then(this.modifier.modifier)
                .then(interactor.modifier.modifier),
            interactor,
            this
        )
    }

}


